import { reqUseraddress, reqgoodslist } from "@/api";
export default {
  namespaced: true,
  actions: {
    // 获得用户地址信息
    async getUserAddress(context) {
      let result = await reqUseraddress()

      if (result.code == 200) {
        console.log(result, '获得用户地址信息')
        context.commit('GETUSERADDRESS', result.data)
      } else {
        return Promise.reject(new Error(result.message))
      }
    },
    //获得用户商品清单
    async getUsergoodslistInfo(context) {
      let result = await reqgoodslist()
      console.log(result, '获得用户商品清单')
      if (result.code == 200) {
        context.commit("GETUSERGOODSLISTINFO", result.data)
      } else {
        return Promise.reject(new Error(result.message))
      }
    }
  },
  mutations: {
    GETUSERADDRESS(state, userAddress) {
      state.userAddress = userAddress
    },
    GETUSERGOODSLISTINFO(state, goodsListInfo) {
      state.goodsListInfo = goodsListInfo
    }
  },
  state: {
    userAddress: [],
    goodsListInfo: {}
  },
  getters: {}
}